package com.coffee.admin.api.common.service;

import com.coffee.admin.api.common.query.SmsCodeQuery;
import com.coffee.admin.api.common.result.SmsCodeResult;
import com.coffee.core.entity.Page;
import com.coffee.core.entity.PagerInfo;
import com.coffee.core.enums.SmsSourceEnum;
import com.coffee.core.exception.BusinessException;

import java.util.List;
import java.util.Map;
import java.util.Set;


public interface SmsCodeService {

    /**
     * 短信验证码有效时间
     */
    int DEFAULT_SMS_AVAILABLE_MINUTES = 10;

    Page<SmsCodeResult> getPager(SmsCodeQuery param, PagerInfo pr);

    Integer count(SmsCodeQuery param);

    SmsCodeResult getDetail(Integer id);

    List<SmsCodeResult> getList(SmsCodeQuery param, PagerInfo pr);

    List<SmsCodeResult> getList(SmsCodeQuery param);

    List<SmsCodeResult> getList();

    void delete(Integer id);

    void addOrUpdate(SmsCodeResult result) throws BusinessException;

    Map<Integer, SmsCodeResult> getItemMap(Set<Integer> idSet);

    Map<Integer, SmsCodeResult> getItemMap();

    /**
     * 短信校验(验证10分钟之内的短信)
     *
     * @param mobile           手机号
     * @param verificationCode 验证码
     * @param smsSource        短信来源
     * @return true if validate successfully else false
     */
    boolean validateSmsCode(String mobile,
                            String verificationCode,
                            SmsSourceEnum smsSource);

    String getSmsTemplate(String smsType) throws BusinessException;


    String sendVerificationCodeSms(String smsType, String mobile, String v) throws BusinessException;

}